package com.psa.system;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import com.psa.adapter.CustomerListAdapter;
import com.psa.tool.*;
import com.wxw.BaseLibrary.tool.ActivityTool;

/**
 * Created by david on 14-3-31.
 */
public class CustRouteActivity extends Activity implements View.OnClickListener{
    private Button btnReturn,btnUnRoute,btnUnPlan,btnSearchRoute;
    private ListView lvRouteList;
    private TextView tvRouteTitle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityTool.hideTitle(this);
        ActivityTool.fullScreen(this);
        ExitApplication.getInstance().addActivity(this);
        setContentView(R.layout.customer_list_view);
        btnReturn = (Button)findViewById(R.id.btnReturn);
        btnReturn.setOnClickListener(this);
        btnSearchRoute = (Button)findViewById(R.id.btnSearchRoute);
        btnSearchRoute.setOnClickListener(this);
        btnUnPlan = (Button)findViewById(R.id.btnUnPlan);
        btnUnPlan.setOnClickListener(this);
        btnUnRoute = (Button)findViewById(R.id.btnUnRoute);
        btnUnRoute.setOnClickListener(this);
        lvRouteList = (ListView)findViewById(R.id.lvRouteList);
        lvRouteList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                if (SystemStatus.currentCustomers==null || i>=SystemStatus.currentCustomers.size() || i<0)return;
                SystemStatus.currentCustomerIndex = i;
                ((CustomerListAdapter)lvRouteList.getAdapter()).setIndex(i);
                CustRouteActivity.this.startActivityForResult(new Intent(CustRouteActivity.this, CustomerActivity.class), 1);
            }
        });
        tvRouteTitle = (TextView)findViewById(R.id.tvRouteTitle);
        lvRouteList.setAdapter(new CustomerListAdapter(this));
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btnReturn:
                this.setResult(1);
                this.finish();
                break;
            case R.id.btnSearchRoute:
                break;
            case R.id.btnUnPlan:
                break;
            case R.id.btnUnRoute:
                break;
        }
    }
}
